<template>
  <a-row :gutter="10">
    <a-col :sm="24" style="margin-bottom: 20px">
      <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <!-- 搜索区域 -->
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <a-form-item :label="$t('系统类型')" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18, offset: 1 }">
                  <a-select v-model="queryParam.id" :placeholder="$t('请选择')">
                    <a-select-option v-for="item in typeList" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="12" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">{{$t('查询')}}</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{$t('重置')}}</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator" style="margin: 5px 0 10px 2px">
          <a-button @click="handleAdd" type="primary">{{$t('新建')}}</a-button>
        </div>

        <div style="margin-top: 15px">
          <a-table
            style="height: 500px"
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange"
          >
            <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">{{$t('编辑')}}</a>
              <a @click="handlePerssion(record.id)" style="margin-left:8px">{{$t('授权')}}</a>
            </span>
          </a-table>
        </div>
        <!-- 右侧的角色权限配置 -->
        <user-role-modal ref="modalUserRole"></user-role-modal>
        <role-modal ref="modalForm" @ok="modalFormOk"></role-modal>
      </a-card>
    </a-col>
  </a-row>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { deleteAction, postAction, getAction } from '@/api/manage'
import RoleModal from './modules/RoleModal'
import { filterObj } from '@/utils/util'
import UserRoleModal from './modules/UserRoleModal'
import moment from 'moment'

export default {
  name: 'SystemTypeManage',
  mixins: [JeecgListMixin],
  components: {
    UserRoleModal,
    RoleModal,
    moment,
  },
  data() {
    return {
      test: {},
      rightcolval: 0,
      queryParam:{
        id:'',
      },
      columns: [
        {
          title: this.$t('类型编码'),
          align: 'center',
          dataIndex: 'code',
        },
        {
          title: this.$t('类型名称'),
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: this.$t('功能配置'),
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],

      // 高级查询参数
      superQueryParams2: '',
      // 高级查询拼接条件
      superQueryMatchType2: 'and',
      url: {
        list: '/system/bisSysType/list',
        delete: '/system/bisSysType/delete',
      },
      typeList:[],
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig(){
      getAction('/system/bisSysType/list',{pageNo: 1,pageSize: 999}).then(res=>{
        if(res.success){
          this.typeList = res.result.records
          this.typeList.push({name:this.$t('全部'),id:'',})
        }else{
          this.$message.warning(res.message)
        }
      })
    },
    getQueryField2() {
      //TODO 字段权限控制
      var str = 'id,'
      this.columns2.forEach(function (value) {
        str += ',' + value.dataIndex
      })
      return str
    },
    handlePerssion(roleId) {
      this.$refs.modalUserRole.show(roleId)
    },
    searchReset(){
      this.queryParam = {
        id:'',
      }
      this.loadData(1)
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
/** Button按钮间距 */
.ant-btn {
  margin-left: 8px;
}
</style>